from datetime import datetime

from sqlmodel import SQLModel, Field, Relationship

from models.relationships.user_project import UserProjectLink
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from models.user import User


class Project(SQLModel, table=True):
    id: int = Field(primary_key=True, index=True)
    name: str = Field(max_length=50)
    members: list["User"] = Relationship(back_populates="project", link_model=UserProjectLink)
    created_at: datetime = Field(default_factory=datetime.now)
    updated_at: datetime = Field(default_factory=datetime.now)
